<template>
  <el-upload class="upload-demo" drag action="/api/admin/file/upload" multiple :on-success="imgSuccess">

    <template #trigger>
      <div v-if="value">
        <el-image :src="`${value}`"></el-image>
      </div>
      <div v-else>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
      </div>

    </template>
    <template #tip>
       <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div>
    </template>




  </el-upload>
</template>

<script>
  export default {
    name: "fileUpload",
    props: {
      value:{
        type:String,
        default:""
      }
    },
    methods: {
      imgSuccess(response) {
        if(response.code == 0){
          let url = response.data.fileurl;
           this.$emit("input",url);
        }
      }
    }
  }
</script>

<style>
</style>
